﻿using System.Collections;
using UnityEngine;


public class MonsterStateFlee : FSMState
{
    private MonsterController monster => fsm.role as MonsterController;
    public override void Enter()
    {
        monster.Flee();
    }

    public override void Exit()
    {

    }

    public override void Update()
    {
        if (monster.Hp <= 0)
        {
            monster.agent.enabled = false;
            return;
        }

        monster.mstui.Hp(monster.Hp);

        //monster.hp += Time.deltaTime;


      

        if ((monster.target.transform.position - monster.transform.position).sqrMagnitude > monster.pursuitOfDistance * monster.pursuitOfDistance)
        {
            monster.agent.speed = 3.5f;
            fsm.SetState("Pursuit");
        }

    }
}
